#!/bin/bash
###################### USAGE ###################### 
# libcreate PROJECT_NAME                          #
###################################################

# SVN=`which svn`
GIT=`which git`
PYTHON=`which python`
NAME=$1
CHANGE_PROJECT_FILE=`sed s/libcreate/changeProject.py/g ${0}`
CHANGE_PROJECT_FILE=`echo ${0} | sed 's/libcreate/changeProject.py/g'`

DIR=`pwd`

if [[ -z ${NAME} ]]; then
    echo '---Pls---enter--the--name--of--the--COMMON-LIB--'
    exit 0
fi

COMMON_LIB_TEMPATE_URL='https://git.oschina.net/antonyzy/TemplateSDK.git'

${GIT} clone ${COMMON_LIB_TEMPATE_URL} ${NAME}

if [[ {CHANGE_PROJECT_FILE} ]]; then
    # echo '---begin--to--update--the--template--project--to--'${NAME}
    rm -rf ${DIR}'/'${NAME}'/.git'
    python ${CHANGE_PROJECT_FILE} ${DIR}'/'${NAME} 'TemplateSDK' ${NAME}
    # echo '---finished---to--update---template--project--'
    echo '---now--you--can--open--'${DIR}'/'${NAME}/${NAME}'Demo.xcodeproj'
else
    echo '--could---not--found--file--[changeProject.py]--'
    echo '--the--file---must--be--exist--in--[~/tools]--'
fi

